#------------------------------------------------------------------------------
# PostgreSQL Client Authentication Configuration File (Managed by Ansible)
#------------------------------------------------------------------------------

# TYPE    DATABASE    USER    ADDRESS    METHOD

{% if postgres_cluster_hosts|length > 0 %}
# cluster:
{% for item in postgres_cluster_hosts %}
host    all    all    {{ item.ip }}/32    md5
{% endfor %}
{% for item in postgres_cluster_hosts %}
host    replication    {{ postgres_replication }}    {{ item.ip }}/32    md5
{% endfor %}
host    replication    {{ postgres_replication }}    127.0.0.1/32    md5
host    replication    {{ postgres_replication }}    ::1/128    md5

{% endif %}
{% if postgres_backup_hosts|length > 0 %}
# backup:
{% for item in postgres_backup_hosts %}
host    all,replication    {{ postgres_backup }}    {{ item.ip }}/32    md5
{% endfor %}
host    all,replication    {{ postgres_backup }}    127.0.0.1/32    md5
host    all,replication    {{ postgres_backup }}    ::1/128    md5

{% endif %}
# remote users:
{% for item in postgres_hba_config %}
{{ item.type }}    {{ item.database }}    {{ item.user }}    {{ item.address }}    {{ item.method }}
{% endfor %}

# local users:
local    all    all    peer
host    all    all    127.0.0.1/32    md5
host    all    all    ::1/128    md5
